<?php
/* @file new-validator.php
 * @author Liuexp
 * @description php interface for creating new validator
 */


require_once("helper.php");
if(!InGroup(GROUP_NEW_VALIDATOR)){
	MsgBox(ACCESS_DENIED);
	exit();
}
if($_GET['op']=='submit')
{
	$bean=R::dispense("validator");
	$bean->import($_POST,"name,language_name,code");
	if(!isValidValidator($bean))MsgBox(INVALID_VALIDATOR);
	else {
		try{
			R::store($bean);
		}
		catch(Exception $e)
		{
			//TODO
		}
	}
}
else {
	try{

		$dwoo=new Dwoo();
		$tpl=new Dwoo_Template_File('template/new-validator.tpl');
		$data=new Dwoo_Data();
		$data->assign('sharetronix_user_id',GetUserID());
		$dwoo->output($tpl,$data);
	}
	catch(Exception $e)
	{
		OJLog("Error in new-validator.php invoking Dwoo:". $e->getMessage());
	}
}
?>
